#ifndef VERTICESALONGTHEARC_H
#define VERTICESALONGTHEARC_H

#include "geometry/math3d.h"
#include "geometry/vertex3D.h"

QList<Vertex3D *> *VerticesAlongTheArc(Vertex3D *fromPoint, Vertex3D *toPoint,
                         Vertex3D *center, double radius,
                         int segment) {
    Vector3D *fromDirection = Math3D::direction(center, fromPoint);
    Vector3D *toDirection = Math3D::direction(center, toPoint);
    // if (roundNumber(fromDirection.length) !== radius ||
    //     roundNumber(toDirection.length) !== radius)
    //     return;

    Vector3D *crossVector = Math3D::crossVectors(fromDirection, toDirection);
    Vector3D *xVector = fromDirection->normalize();
    Vector3D *yVector = Math3D::crossVectors(crossVector, xVector)->normalize();
    double angle = Math3D::angleOfTwoVectorsInRad(fromDirection, toDirection);

    double dividedAngle = angle / segment;

    QList<Vertex3D *> *returnArray = new QList<Vertex3D *>();
    for (int s = 0; s <= segment; s++) {
        if (s == 0) returnArray->push_back(fromPoint);
        else if (s == segment) returnArray->push_back(toPoint);
        else returnArray->push_back(
                    center->addVectors(xVector->multiply(radius * cos(dividedAngle * s)))
                    ->addVectors(yVector->multiply(radius * sin(dividedAngle * s))));
    }

    return returnArray;
}

#endif // VERTICESALONGTHEARC_H
